<?php
/**
 * Created by PhpStorm.
 * User: DELL
 * Date: 2018/9/26
 * Time: 11:28
 */
namespace app\api\validate;
use app\lib\exception\ParameterException;
use think\Exception;
use think\Validate;
use think\Request;
class BaseValidate extends Validate{
    public function goCheck()
    {
        //必须设置contetn-type:application/json
        $request = Request::instance();
        $params = $request->param();
        $result=$this->batch()->check($params);
        if(!$result){
            $e= new ParameterException([
            'msg'=>$this->error,
            ]);
//            $e->msg=$this->error;
            throw $e;
           /* $error=$this->error;
            throw new Exception($error);*/
        }else{
            return true;
        }

    }

}